# -*- coding:utf-8 -*-
'''
inputDialog
'''
__author__ = 'Tony Zhu'

from PyQt5.QtWidgets import QApplication, QWidget, QLineEdit, QInputDialog, QGridLayout, QLabel, QPushButton, QFrame
from PyQt5.QtCore import *
from PyQt5.QtGui import *

class InputDialog(QWidget):
    def __init__(self,txnr,ztdx):
        super(InputDialog, self).__init__()
        self.setWindowFlags(Qt.Tool | Qt.WindowMinimizeButtonHint| Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint)
        self.txnr = txnr
        self.ztdx = ztdx
        self.initUi()


    def initUi(self):
        self.setWindowTitle("提醒")
        self.setGeometry(200, 200, 200, 100)

        label1 = QLabel(self.txnr)
        label1.setAlignment(Qt.AlignCenter)
        label1.setFont(QFont("Roman times", self.ztdx))

        self.nameLable = QLineEdit("请输入激活码，关闭本弹窗")
        # self.nameLable.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.styleLable = QLabel("外包")
        self.styleLable.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.numberLable = QLabel("40")
        self.numberLable.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.costLable = QLabel("400.98")
        self.costLable.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.introductionLable = QLabel("服务外包第三方公司")
        self.introductionLable.setFrameStyle(QFrame.Panel | QFrame.Sunken)

        nameButton = QPushButton("清除任务")
        nameButton.clicked.connect(self.selectName)
        styleButton = QPushButton("...")
        styleButton.clicked.connect(self.selectStyle)
        numberButton = QPushButton("...")
        numberButton.clicked.connect(self.selectNumber)
        costButton = QPushButton("...")
        costButton.clicked.connect(self.selectCost)
        introductionButton = QPushButton("...")
        introductionButton.clicked.connect(self.selectIntroduction)

        mainLayout = QGridLayout()
        mainLayout.addWidget(label1, 0, 0)
        mainLayout.addWidget(self.nameLable, 1, 0)
        mainLayout.addWidget(nameButton, 1, 1)


        self.setLayout(mainLayout)

    def selectName(self):
        inputext =  self.nameLable.text()
        print("inputext"+inputext)
        return inputext

    def selectStyle(self):
        list = ["外包", "自研"]

        style, ok = QInputDialog.getItem(self, "项目性质", "请选择项目性质：", list)
        if ok:
            self.styleLable.setText(style)

    def selectNumber(self):
        number, ok = QInputDialog.getInt(self, "项目成员", "请输入项目成员人数：", int(self.numberLable.text()), 20, 100, 2)
        if ok:
            self.numberLable.setText(str(number))

    def selectCost(self):
        cost, ok = QInputDialog.getDouble(self, "项目成本", "请输入项目成员人数：", float(self.costLable.text()), 100.00, 500.00, 2)
        if ok:
            self.costLable.setText(str(cost))

    def selectIntroduction(self):
        introduction, ok = QInputDialog.getMultiLineText(self, "项目介绍", "介绍：", "服务外包第三方公司 \nPython project")
        if ok:
            self.introductionLable.setText(introduction)


if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    myshow = InputDialog('您好，该维修了您好，该维修了您好，该维修了您好，该维修了您好，该维修了您好，该维修了您好，该维修了',15)
    myshow.show()
    myshow1 = InputDialog('1您好，该维修了您好，该维修了您好，该维修了您好，该维修了您好，该维修了您好，该维修了您好，该维修了', 15)
    myshow1.show()
    sys.exit(app.exec_())